# Fixing mistakes ---------------------------------------------------------

lab$id[lab$instanceID=="uuid:ee254983-4f54-40c8-b94b-216143360d48"] <- "215134"
lab$id[lab$instanceID=="uuid:485d4eb2-2c4b-4df0-b735-7778f6028c89"] <- "215135"
lab$id[lab$instanceID=="uuid:617b36ae-9f97-487f-83d5-afc7beda18f9"] <- "215136"
lab$id[lab$instanceID=="uuid:6f98efa2-071b-4cf0-b2e6-2892257383b8"] <- "215138"
lab$id[lab$instanceID=="uuid:d211dc65-670b-4f0f-8e89-1dd48c620efb"] <- "215139"
lab$id[lab$instanceID=="uuid:03c145ca-58ed-4977-b0d1-1539266b41f1"] <- "215140"
lab$id[lab$instanceID=="uuid:f423f0c6-abf7-45af-bcfb-de7d0e9bc122"] <- "215142"

lab$randomization_ID[lab$instanceID=="uuid:96585e08-13a2-4351-a51e-747b310a152b"] <- 11
lab$randomization_ID[lab$instanceID=="uuid:179c8f0a-d8c8-4595-8b66-659848aea750"] <- 28

# Coding time variables ---------------------------------------------------

time_stamps <- names(lab)[grepl(pattern = "\\btime_",x = names(lab))]
bookends <- c("starttime","endtime","date_time")


for(variable in time_stamps){
	lab[,variable] <- as.POSIXct(strptime(lab[,variable],"%Y-%b-%d %H:%M:%S"),format = "%Y-%b-%d %I:%M:%S",tz = "Etc/GMT+3") 
}

for(variable in bookends){
	lab[,variable] <- as.POSIXct(strptime(lab[,variable],"%b %d, %Y %I:%M:%S %p"),format = "%b %d, %Y %I:%M:%S %p",tz = "Etc/GMT+3")
}

rm(time_stamps, bookends, variable)

# Removing trial observations ---------------------------------------------

lab <- subset(lab, starttime > as.POSIXct("2017-07-09",tz = "Etc/GMT+3"))

lab$tc_id <- lab$tc
